//
//  HomeSetupPopView.m
//  markmap
//
//  Created by 甘世清 on 2024/9/11.
//

#import "HomeSetupPopView.h"

@implementation HomeSetupPopView

+(void)SQ_Show{
   
    HomeSetupPopView * vc = [[HomeSetupPopView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDETH, 280)];
    vc.index = [UserModel share].isShow;
    LSTPopView * pop = [LSTPopView initWithCustomView:vc
                                           parentView:nil
                                             popStyle:LSTPopStyleSmoothFromBottom dismissStyle:LSTDismissStyleSmoothToBottom];
    pop.hemStyle = LSTHemStyleBottom;
  
    [pop pop];
    LSTPopViewWK(pop)
    [pop setBgClickBlock:^{
        [wk_pop dismiss];
    }];
    [vc setAddSuccessfulBlock:^{
        [wk_pop dismiss];
    }];
    
    
}
- (void)SQ_UIViewForSelfView{
    self.backgroundColor = SQColorF4F4F4;
    self.layer.cornerRadius = 20;
    
    UILabel * label = [[UILabel alloc]init];
    label.text = SQNSLocalString(@"设置个人位置信息");
    label.textColor = UIColor.blackColor;
    label.font = FONT_MEDIUM(16);
    [self addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self).offset(25);
    }];
    self.backgroundColor = UIColor.whiteColor;
    self.layer.cornerRadius = 32;
    [self addSubview:self.gongkai];
    [self.gongkai mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.width.mas_equalTo(SCREEN_WIDETH-40);
        make.height.mas_equalTo(40);
        make.top.equalTo(self).offset(90);
    }];
    [self addSubview:self.shiren];
    [self.shiren mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.width.mas_equalTo(SCREEN_WIDETH-40);
        make.height.mas_equalTo(40);
        make.top.equalTo(self).offset(150);
    }];
    WS(weakSelf);
    [self.gongkai setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [weakSelf sq_gongkai];
    }];
    [self.shiren setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [weakSelf sq_shiren];
    }];
}
-(void)sq_gongkai{
    [YJProgressHUD SQ_showMsgWithoutView:@""];
   NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [dic setObject:@"1" forKey:@"isShow"];
    [HttpTool post:Url5 paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        if (self.addSuccessfulBlock) {
            self.addSuccessfulBlock();
        }
        UserModel * model =[UserModel share];
        model.isShow = YES;
        [UserModel updateLocalUserModel:model];
        } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
            [YJProgressHUD showMsgWithoutView:httpModel.message];
        }];
}
-(void)sq_shiren{
    [YJProgressHUD SQ_showMsgWithoutView:@""];
   NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [dic setObject:@"0" forKey:@"isShow"];
    [HttpTool post:Url5 paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        if (self.addSuccessfulBlock) {
            self.addSuccessfulBlock();
        }
        UserModel * model =[UserModel share];
        model.isShow = NO;
        [UserModel updateLocalUserModel:model];
        } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
            [YJProgressHUD showMsgWithoutView:httpModel.message];
        }];
}
- (void)setIndex:(BOOL)index{
    _index = index;
    if (index) {
        self.gongkai.image = SQGetImage(@"选中");
    } else {
        self.shiren.image = SQGetImage(@"选中");
    }
}
- (SQCustomButton *)gongkai{
    if (!_gongkai) {
        _gongkai = [[SQCustomButton alloc]initType:SQCustomButtonRightImageType imageSize:CGSizeMake(24, 24) midmargin:5];
        _gongkai.text = SQNSLocalString(@"公开个人位置信息");
        _gongkai.font = FONT_MEDIUM(14);
        _gongkai.textColor = UIColor.blackColor;
        _gongkai.layer.cornerRadius = 20;
        _gongkai.layer.borderWidth = 1;
        _gongkai.layer.borderColor =  SQColor(@"#000000").CGColor;
    }
    return _gongkai;
}
- (SQCustomButton *)shiren{
    if (!_shiren) {
        _shiren = [[SQCustomButton alloc]initType:SQCustomButtonRightImageType imageSize:CGSizeMake(24, 24) midmargin:5];
        _shiren.text = SQNSLocalString(@"隐藏个人位置信息");
        _shiren.font = FONT_MEDIUM(14);
        _shiren.layer.cornerRadius = 20;
        _shiren.textColor = UIColor.blackColor;
        _shiren.layer.borderWidth = 1;
        _shiren.layer.borderColor =  SQColor(@"#000000").CGColor;
        
    }
    return _shiren;
}
@end
